package fr.um2.physique.risa.gui;
import fr.um2.physique.risa.core.process.ConvolveG;
import fr.um2.physique.risa.display.ImageViewer;

/**
 * Controller class for the gaussian convolution function.
 * 
 * @author Mathilde Salthun-Lassalle
 */

public class GaussConvolveController {

	GaussConvolveTab view;

	// instancier le mod�le

	public GaussConvolveTab getView() {
		return view;
	}

	public void setView(GaussConvolveTab view) {
		this.view = view;
	}

	/**
	 * 
	 * asks for the view to display input dialog box for parameters
	 * 
	 * @return String its value
	 */
	public String askForParameter(String parameter) {
		view = new GaussConvolveTab();
		return (String) view.displayInputForParameter(parameter);

	}

	/**
	 * Displays the image with gaussian convolution. Creates an ImageViewer (or
	 * view) of the result.
	 * 
	 * @param int radius, float sigma ( Gaussian width )
	 */
	public void displayGaussianConvolution(int radius, float sigma) {
		if (sigma == 0) {
			throw new IllegalArgumentException("Uncorrect value for sigma");
		}
		if (radius <1) {
			throw new IllegalArgumentException("Uncorrect value for radius");
		}
		ConvolveG convo = new ConvolveG();
		convo.CreerNoyau(radius, sigma);
		
		new ImageViewer(convo.getConvolvedImage(), convo.getType());
		
	}

}
